home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / System Utilities / Speech Manager1.1.1 / Interfaces ƒ / Speech.p < prev    next >
Encoding:
Text File  |  1993-07-20  |  8.4 KB  |  294 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        Speech.p
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    xxx put writers here xxx
  7.  
  8.     Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <1+>     6/18/93    MC        
  13.  
  14. }
  15.  
  16.  
  17. Unit Speech;
  18. Interface
  19.  
  20. Uses
  21.     MemTypes,
  22.     OSIntf,
  23.     ToolIntf,
  24.     SysEqu,
  25.     Components;
  26.  
  27.  
  28. CONST
  29.  
  30.     gestaltSpeechAttr = 'ttsc';        { Gestalt Manager selector for Speech Attributes }
  31.     gestaltSpeechMgrPresent = 0;    { Gestalt bit which indicates that Speech Manager exists }
  32.  
  33.  
  34. kTextToSpeechSynthType         = 'ttsc';    { Text-to-Speech Synthesizer component type     }
  35. kTextToSpeechVoiceType         = 'ttvd';    { Text-to-Speech Voice resource type             }
  36. kTextToSpeechVoiceFileType     = 'ttvf';    { Text-to-Speech Voice file type                 }
  37. kTextToSpeechVoiceBundleType = 'ttvb';    { Text-to-Speech Voice Bundle file type            }
  38.  
  39.     { Speech Manager error codes (Range from 240 - 259) }
  40.     
  41.     noSynthFound         = -240;
  42.     synthOpenFailed     = -241;
  43.     synthNotReady        = -242;
  44.     bufTooSmall         = -243;
  45.     voiceNotFound        = -244;
  46.     incompatibleVoice    = -245;
  47.     badDictFormat         = -246;
  48.     badInputText         = -247;
  49.         
  50.     { constants for SpeakBuffer and TextDone callback controlFlags bits }
  51.     
  52.     kNoEndingProsody     = 1;
  53.     kNoSpeechInterrupt     = 2;
  54.     kPreflightThenPause    = 4;    
  55.     
  56.     
  57.     { constants for StopSpeechAt and PauseSpeechAt }
  58.     
  59.     kImmediate        = 0;
  60.     kEndOfWord        = 1;
  61.     kEndOfSentence    = 2;
  62.     
  63.     
  64.     
  65.     { GetSpeechInfo & SetSpeechInfo selectors }
  66.     
  67.     soStatus                = 'stat';
  68.     soErrors                = 'erro';
  69.     soInputMode                = 'inpt';
  70.     soCharacterMode            = 'char';
  71.     soNumberMode            = 'nmbr';
  72.     soRate                    = 'rate';
  73.     soPitchBase                = 'pbas';
  74.     soPitchMod                = 'pmod';
  75.     soVolume                = 'volm';
  76.     soSynthType                = 'vers';
  77.     soRecentSync            = 'sync';
  78.     soPhonemeSymbols        = 'phsy';
  79.     soCurrentVoice            = 'cvox';
  80.     soCommandDelimiter        = 'dlim';
  81.     soReset                    = 'rset';
  82.     soCurrentA5                = 'myA5';
  83.     soRefCon                = 'refc';
  84.     soTextDoneCallBack        = 'tdcb';
  85.     soSpeechDoneCallBack    = 'sdcb';
  86.     soSyncCallBack            = 'sycb';
  87.     soErrorCallBack            = 'ercb';
  88.     soPhonemeCallBack        = 'phcb';
  89.     soWordCallBack            = 'wdcb';
  90.     soSynthExtension        = 'xtnd';
  91.  
  92.  
  93.     { Speaking Mode Constants }
  94.  
  95.     modeText        = 'TEXT';        { input mode constants     }
  96.     modePhonemes    = 'PHON';
  97.     modeNormal        = 'NORM';        { character mode and number mode constants }
  98.     modeLiteral        = 'LTRL';
  99.  
  100.     { GetVoiceInfo selectors }
  101.     
  102.     soVoiceDescription    = 'info';    { gets basic voice info }
  103.     soVoiceFile            = 'fref';    { gets voice file ref info }
  104.  
  105.  
  106.     kNeuter     = 0;
  107.     kMale        = 1;
  108.     kFemale        = 2;
  109.  
  110.  
  111.  
  112.  
  113. TYPE
  114.  
  115.     SpeechChannelRecord = Longint;
  116.     SpeechChannel = ^SpeechChannelRecord;
  117.     SpeechChannelPtr = ^SpeechChannel;
  118.  
  119.  
  120.     VoiceSpec =
  121.         RECORD
  122.             creator:    OSType;            { creator id of required synthesizer     }
  123.             id:            OSType;            { voice id on the specified synth         }
  124.         END;
  125.     VoiceSpecPtr = ^VoiceSpec;
  126.  
  127.  
  128.     VoiceDescription =
  129.         RECORD
  130.             length:        Longint;                { size of structure - set by application     }
  131.             voice:        VoiceSpec;                { voice creator and id info             }
  132.             version:    Longint;                { version code for voice                 }
  133.             name:        Str63;                    { name of voice                         }
  134.             comment:    Str255;                    { additional text info about voice         }
  135.             gender:        Integer;                { neuter, male, or female                }
  136.             age:        Integer;                { approximate age in years                 }
  137.             script:        Integer;                { script code of text voice can process }
  138.             language:    Integer;                { language code of voice output speech     }
  139.             region:        Integer;                { region code of voice output speech     }
  140.             reserved1:    Longint;                { always zero - reserved for future use    }
  141.             reserved2:    Longint;                { always zero - reserved for future use    }
  142.             reserved3:    Longint;                { always zero - reserved for future use    }
  143.             reserved4:    Longint;                { always zero - reserved for future use    }
  144.         END;
  145.     VoiceDescriptionPtr = ^VoiceDescription;
  146.  
  147.     VoiceFileInfo =
  148.         RECORD
  149.             fileSpec:    FSSpec;                    { volume, dir, & name information for voice file }
  150.             resID:        Integer;                { resource id of voice in the file }
  151.         END;
  152.     VoiceFileInfoPtr = ^VoiceFileInfo;
  153.  
  154.  
  155.  
  156.     SpeechStatusInfo = 
  157.         RECORD
  158.             outputBusy:        Boolean; { TRUE if audio is playing}
  159.             outputPaused:    Boolean; { TRUE if channel is paused}
  160.             inputBytesLeft:    Longint; { bytes of input left to process}
  161.             phonemeCode:    Integer; { code for current phoneme}
  162.         END;
  163.     SpeechStatusInfoPtr = ^SpeechStatusInfo;
  164.     
  165.     
  166.     
  167.     
  168.     SpeechModeInfo = 
  169.         RECORD
  170.             inputMode:        OSType;    {'TEXT' or 'PHON'}
  171.             characterMode:    OSType;    {'NORM' or 'LTRL'}
  172.             numberMode:        OSType;    {'NORM' or 'LTRL'}
  173.  
  174.         END;
  175.     SpeechModeInfoPtr = ^SpeechModeInfo;
  176.     
  177.     
  178.     SpeechVersionInfo = 
  179.         RECORD
  180.             synthType:            OSType;            { always ‘ttsc’ }
  181.             synthSubType:        OSType;            { Flavor of synth }
  182.             synthManufacturer:    OSType;            { synth creator ID }
  183.             synthFlags:            Longint;        { synth feature flags }
  184.             synthVersion:        NumVersion;     { synth version number }
  185.         END;
  186.     SpeechVersionInfoPtr = ^SpeechVersionInfo;
  187.     
  188.     
  189.     TYPE speechXtndData = 
  190.         RECORD
  191.             synthCreator:    OSType;                        {synthesizer ID selector}
  192.             synthData:        PACKED ARRAY [0..1] of Char;{ data bytes TBD by synthesizer }
  193.         END;
  194.     
  195.     DelimiterInfo =
  196.         RECORD
  197.             startDelimiter:    PACKED ARRAY [0..1] of Char;
  198.             endDelimiter:    PACKED ARRAY [0..1] of Char;
  199.         END;
  200.     
  201.  
  202.     SpeechErrorInfo =
  203.         RECORD
  204.             count:        Integer;            { # of errs since last check         }
  205.             oldest:        OSErr;                { oldest unread error                 }
  206.             oldPos:        Longint;            { char position of oldest err         }
  207.             newest:        OSErr;                { most recent error                 }
  208.             newPos:        Longint;            { char position of newest err         }
  209.         END;
  210.  
  211.  
  212.     PhonemeInfo =
  213.         RECORD
  214.             opcode:            Integer;        { opcode for the phoneme             }
  215.             phStr:            Str15;            { corresponding char string         }
  216.             exampleStr:        Str31;            { word that shows use of phoneme     }
  217.             hiliteStart:    Integer;        { segment of example word that         }
  218.             hiliteEnd:        Integer;        { should be hilighted (ala TextEdit) }
  219.         END;
  220.  
  221.     PhonemeDescriptor =
  222.         RECORD
  223.             phonemeCount:    Integer;                         { # of elements     }
  224.             thePhonemes:    ARRAY [0..0] of PhonemeInfo;     { element list         }
  225.         END;
  226.  
  227.  
  228.  
  229. FUNCTION  SpeechManagerVersion: NumVersion;
  230.     INLINE $203C,$0000,$000C,$A800;
  231.  
  232. FUNCTION  MakeVoiceSpec ( creator: OSType; id: OSType; voice: VoiceSpecPtr): OSErr;
  233.     INLINE $203C, $0604, $000C, $A800;
  234. FUNCTION CountVoices (VAR numVoices: Integer): OSErr;
  235.     INLINE $203C, $0108, $000C, $A800;
  236. FUNCTION GetIndVoice (index: Integer; voice: VoiceSpecPtr): OSErr;
  237.     INLINE $203C, $030C, $000C, $A800;
  238. FUNCTION GetVoiceDescription (voice: VoiceSpecPtr; info: VoiceDescriptionPtr; infoLength: Longint): OSErr;
  239.     INLINE $203C, $0610, $000C, $A800;
  240. FUNCTION GetVoiceInfo (voice: VoiceSpecPtr; selector: OSType; voiceInfo: Ptr): OSErr;
  241.     INLINE $203C, $0614, $000C, $A800;
  242.  
  243. FUNCTION StopSpeech (chan: SpeechChannel): OSErr;
  244.     INLINE $203C, $022C, $000C, $A800;
  245.  
  246. FUNCTION SetSpeechRate (chan: SpeechChannel; rate: Fixed): OSErr;
  247.     INLINE $203C, $0444, $000C, $A800;
  248. FUNCTION GetSpeechRate (chan: SpeechChannel; rate: FixedPtr): OSErr;
  249.     INLINE $203C, $0448, $000C, $A800;
  250. FUNCTION SetSpeechPitch (chan: SpeechChannel; pitch: Fixed): OSErr;
  251.     INLINE $203C, $044C, $000C, $A800;
  252. FUNCTION GetSpeechPitch (chan: SpeechChannel; pitch: FixedPtr): OSErr;
  253.     INLINE $203C, $0450, $000C, $A800;
  254.  
  255. FUNCTION UseDictionary (chan: SpeechChannel; dictionary: Handle): OSErr;
  256.     INLINE $203C, $0460, $000C, $A800;
  257.     
  258.  
  259.     
  260. FUNCTION  NewSpeechChannel( voice: VoiceSpecPtr; VAR chan: SpeechChannel): OSErr;
  261.     INLINE $203C, $0418, $000C,$A800;
  262. FUNCTION  DisposeSpeechChannel( chan: SpeechChannel): OSErr;
  263.     INLINE $203C, $021C, $000C,$A800;
  264.  
  265. FUNCTION  SpeakString( s: Str255): OSErr;
  266.     INLINE $203C, $0220, $000C,$A800;
  267. FUNCTION  SpeakText( chan: SpeechChannel; textBuf: Ptr; byteLen: LongInt): OSErr;
  268.     INLINE $203C, $0624, $000C,$A800;
  269. FUNCTION  SpeakBuffer( chan: SpeechChannel; textBuf: Ptr; byteLen: LongInt; controlFlags: LongInt ): OSErr;
  270.     INLINE $203C, $0828, $000C,$A800;
  271.  
  272. FUNCTION  StopSpeechAt (chan: SpeechChannel; whereToStop: LongInt) : OSErr;
  273.     INLINE $203C, $0430, $000C,$A800;
  274. FUNCTION  PauseSpeechAt (chan: SpeechChannel; whereToPause: LongInt) : OSErr;
  275.     INLINE $203C, $0434, $000C,$A800;
  276. FUNCTION  ContinueSpeech (chan: SpeechChannel) : OSErr;
  277.     INLINE $203C, $0238, $000C,$A800;
  278.  
  279. FUNCTION  SpeechBusy: Integer;
  280.     INLINE $203C, $003C, $000C,$A800;
  281. FUNCTION  SpeechBusySystemWide: Integer;
  282.     INLINE $203C, $0040, $000C,$A800;
  283.  
  284. FUNCTION  GetSpeechInfo (chan: SpeechChannel; selector: OSType; speechInfo: Ptr) : OSErr;
  285.     INLINE $203C, $0658, $000C,$A800;
  286. FUNCTION  SetSpeechInfo (chan: SpeechChannel; selector: OSType; speechInfo: Ptr) : OSErr;
  287.     INLINE $203C, $0654, $000C,$A800;
  288.  
  289. FUNCTION  TextToPhonemes (chan: SpeechChannel; textBuf: Ptr; textBytes: LongInt; phonemeBuf: Handle; phonemeBytes: LongIntPtr) : OSErr;
  290.     INLINE $203C, $0A5C, $000C,$A800;
  291.  
  292. END.
  293.  
  294.